/*
               File: C37
        Description: Conversion for table MMCLI20
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 18 de Junio de 2010 12:37:35.36
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class c37 extends GXProcedure
{
   public c37( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( c37.class ), "" );
   }

   public c37( int remoteHandle ,
               ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor C372 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A289ConUUM = C372_A289ConUUM[0] ;
         A288ConHUM = C372_A288ConHUM[0] ;
         A287ConFUM = C372_A287ConFUM[0] ;
         A286ConUCR = C372_A286ConUCR[0] ;
         A285ConHCR = C372_A285ConHCR[0] ;
         A284ConFCR = C372_A284ConFCR[0] ;
         A283ConTlf = C372_A283ConTlf[0] ;
         A282ConTlf = C372_A282ConTlf[0] ;
         A281ConTlf = C372_A281ConTlf[0] ;
         A280ConTlf = C372_A280ConTlf[0] ;
         A279ConTlf = C372_A279ConTlf[0] ;
         A278ConTlf = C372_A278ConTlf[0] ;
         A130CrgCod = C372_A130CrgCod[0] ;
         A277PrsAso = C372_A277PrsAso[0] ;
         A35PrsCod = C372_A35PrsCod[0] ;
         /*
            INSERT RECORD ON TABLE GXA0037

         */
         AV2PrsCod = A35PrsCod ;
         AV3CliCod = 0 ;
         AV4PrsAsoC = A277PrsAso ;
         if ( C372_n130CrgCod[0] )
         {
            AV5CrgCod = 0 ;
         }
         else
         {
            AV5CrgCod = A130CrgCod ;
         }
         if ( C372_n278ConTlf[0] )
         {
            AV6ConTlfF = "" ;
         }
         else
         {
            AV6ConTlfF = A278ConTlf ;
         }
         if ( C372_n279ConTlf[0] )
         {
            AV7ConTlfF = "" ;
         }
         else
         {
            AV7ConTlfF = A279ConTlf ;
         }
         if ( C372_n280ConTlf[0] )
         {
            AV8ConTlfM = "" ;
         }
         else
         {
            AV8ConTlfM = A280ConTlf ;
         }
         if ( C372_n281ConTlf[0] )
         {
            AV9ConTlfM = "" ;
         }
         else
         {
            AV9ConTlfM = A281ConTlf ;
         }
         if ( C372_n282ConTlf[0] )
         {
            AV10ConTlf = "" ;
         }
         else
         {
            AV10ConTlf = A282ConTlf ;
         }
         if ( C372_n283ConTlf[0] )
         {
            AV11ConTlf = "" ;
         }
         else
         {
            AV11ConTlf = A283ConTlf ;
         }
         if ( C372_n284ConFCR[0] )
         {
            AV12ConFCR = GXutil.nullDate() ;
         }
         else
         {
            AV12ConFCR = A284ConFCR ;
         }
         if ( C372_n285ConHCR[0] )
         {
            AV13ConHCR = "" ;
         }
         else
         {
            AV13ConHCR = A285ConHCR ;
         }
         if ( C372_n286ConUCR[0] )
         {
            AV14ConUCR = "" ;
         }
         else
         {
            AV14ConUCR = A286ConUCR ;
         }
         if ( C372_n287ConFUM[0] )
         {
            AV15ConFUM = GXutil.nullDate() ;
         }
         else
         {
            AV15ConFUM = A287ConFUM ;
         }
         if ( C372_n288ConHUM[0] )
         {
            AV16ConHUM = "" ;
         }
         else
         {
            AV16ConHUM = A288ConHUM ;
         }
         if ( C372_n289ConUUM[0] )
         {
            AV17ConUUM = "" ;
         }
         else
         {
            AV17ConUUM = A289ConUUM ;
         }
         /* Using cursor C373 */
         pr_default.execute(1, new Object[] {AV2PrsCod, new Short(AV3CliCod), AV4PrsAsoC, new Short(AV5CrgCod), AV6ConTlfF, AV7ConTlfF, AV8ConTlfM, AV9ConTlfM, AV10ConTlf, AV11ConTlf, AV12ConFCR, AV13ConHCR, AV14ConUCR, AV15ConFUM, AV16ConHUM, AV17ConUUM});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      C372_A289ConUUM = new String[] {""} ;
      C372_A288ConHUM = new String[] {""} ;
      C372_A287ConFUM = new java.util.Date[] {GXutil.nullDate()} ;
      C372_A286ConUCR = new String[] {""} ;
      C372_A285ConHCR = new String[] {""} ;
      C372_A284ConFCR = new java.util.Date[] {GXutil.nullDate()} ;
      C372_A283ConTlf = new String[] {""} ;
      C372_A282ConTlf = new String[] {""} ;
      C372_A281ConTlf = new String[] {""} ;
      C372_A280ConTlf = new String[] {""} ;
      C372_A279ConTlf = new String[] {""} ;
      C372_A278ConTlf = new String[] {""} ;
      C372_A130CrgCod = new short[1] ;
      C372_A277PrsAso = new String[] {""} ;
      C372_A35PrsCod = new String[] {""} ;
      A289ConUUM = "" ;
      A288ConHUM = "" ;
      A287ConFUM = GXutil.nullDate() ;
      A286ConUCR = "" ;
      A285ConHCR = "" ;
      A284ConFCR = GXutil.nullDate() ;
      A283ConTlf = "" ;
      A282ConTlf = "" ;
      A281ConTlf = "" ;
      A280ConTlf = "" ;
      A279ConTlf = "" ;
      A278ConTlf = "" ;
      A130CrgCod = 0 ;
      A277PrsAso = "" ;
      A35PrsCod = "" ;
      GIGXA0037 = 0 ;
      AV2PrsCod = "" ;
      AV3CliCod = 0 ;
      AV4PrsAsoC = "" ;
      C372_n130CrgCod = new boolean[] {false} ;
      AV5CrgCod = 0 ;
      C372_n278ConTlf = new boolean[] {false} ;
      AV6ConTlfF = "" ;
      C372_n279ConTlf = new boolean[] {false} ;
      AV7ConTlfF = "" ;
      C372_n280ConTlf = new boolean[] {false} ;
      AV8ConTlfM = "" ;
      C372_n281ConTlf = new boolean[] {false} ;
      AV9ConTlfM = "" ;
      C372_n282ConTlf = new boolean[] {false} ;
      AV10ConTlf = "" ;
      C372_n283ConTlf = new boolean[] {false} ;
      AV11ConTlf = "" ;
      C372_n284ConFCR = new boolean[] {false} ;
      AV12ConFCR = GXutil.nullDate() ;
      C372_n285ConHCR = new boolean[] {false} ;
      AV13ConHCR = "" ;
      C372_n286ConUCR = new boolean[] {false} ;
      AV14ConUCR = "" ;
      C372_n287ConFUM = new boolean[] {false} ;
      AV15ConFUM = GXutil.nullDate() ;
      C372_n288ConHUM = new boolean[] {false} ;
      AV16ConHUM = "" ;
      C372_n289ConUUM = new boolean[] {false} ;
      AV17ConUUM = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new c37__default(),
         new Object[] {
             new Object[] {
            C372_A289ConUUM, C372_n289ConUUM, C372_A288ConHUM, C372_n288ConHUM, C372_A287ConFUM, C372_n287ConFUM, C372_A286ConUCR, C372_n286ConUCR, C372_A285ConHCR, C372_n285ConHCR,
            C372_A284ConFCR, C372_n284ConFCR, C372_A283ConTlf, C372_n283ConTlf, C372_A282ConTlf, C372_n282ConTlf, C372_A281ConTlf, C372_n281ConTlf, C372_A280ConTlf, C372_n280ConTlf,
            C372_A279ConTlf, C372_n279ConTlf, C372_A278ConTlf, C372_n278ConTlf, C372_A130CrgCod, C372_n130CrgCod, C372_A277PrsAso, C372_A35PrsCod
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short A130CrgCod ;
   private short AV3CliCod ;
   private short AV5CrgCod ;
   private short Gx_err ;
   private int GIGXA0037 ;
   private String A289ConUUM ;
   private String A288ConHUM ;
   private String A286ConUCR ;
   private String A285ConHCR ;
   private String A283ConTlf ;
   private String A282ConTlf ;
   private String A281ConTlf ;
   private String A280ConTlf ;
   private String A279ConTlf ;
   private String A278ConTlf ;
   private String A277PrsAso ;
   private String A35PrsCod ;
   private String AV2PrsCod ;
   private String AV4PrsAsoC ;
   private String AV6ConTlfF ;
   private String AV7ConTlfF ;
   private String AV8ConTlfM ;
   private String AV9ConTlfM ;
   private String AV10ConTlf ;
   private String AV11ConTlf ;
   private String AV13ConHCR ;
   private String AV14ConUCR ;
   private String AV16ConHUM ;
   private String AV17ConUUM ;
   private String Gx_emsg ;
   private java.util.Date A287ConFUM ;
   private java.util.Date A284ConFCR ;
   private java.util.Date AV12ConFCR ;
   private java.util.Date AV15ConFUM ;
   private IDataStoreProvider pr_default ;
   private String[] C372_A289ConUUM ;
   private String[] C372_A288ConHUM ;
   private java.util.Date[] C372_A287ConFUM ;
   private String[] C372_A286ConUCR ;
   private String[] C372_A285ConHCR ;
   private java.util.Date[] C372_A284ConFCR ;
   private String[] C372_A283ConTlf ;
   private String[] C372_A282ConTlf ;
   private String[] C372_A281ConTlf ;
   private String[] C372_A280ConTlf ;
   private String[] C372_A279ConTlf ;
   private String[] C372_A278ConTlf ;
   private short[] C372_A130CrgCod ;
   private String[] C372_A277PrsAso ;
   private String[] C372_A35PrsCod ;
   private boolean[] C372_n130CrgCod ;
   private boolean[] C372_n278ConTlf ;
   private boolean[] C372_n279ConTlf ;
   private boolean[] C372_n280ConTlf ;
   private boolean[] C372_n281ConTlf ;
   private boolean[] C372_n282ConTlf ;
   private boolean[] C372_n283ConTlf ;
   private boolean[] C372_n284ConFCR ;
   private boolean[] C372_n285ConHCR ;
   private boolean[] C372_n286ConUCR ;
   private boolean[] C372_n287ConFUM ;
   private boolean[] C372_n288ConHUM ;
   private boolean[] C372_n289ConUUM ;
}

final class c37__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("C372", "SELECT [ConUUM], [ConHUM], [ConFUM], [ConUCR], [ConHCR], [ConFCR], [ConTlfAnx2], [ConTlfAnx1], [ConTlfMov2], [ConTlfMov1], [ConTlfFij2], [ConTlfFij1], [CrgCod], [PrsAsoCod], [PrsCod] FROM [MMCON10] WITH (NOLOCK) ORDER BY [PrsCod], [PrsAsoCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("C373", "INSERT INTO [GXA0037] ([PrsCod], [CliCod], [PrsAsoCod], [CrgCod], [ConTlfFij1], [ConTlfFij2], [ConTlfMov1], [ConTlfMov2], [ConTlfAnx1], [ConTlfAnx2], [ConFCR], [ConHCR], [ConUCR], [ConFUM], [ConHUM], [ConUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((String[]) buf[2])[0] = rslt.getString(2, 8) ;
               ((boolean[]) buf[3])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(3) ;
               ((boolean[]) buf[5])[0] = rslt.wasNull();
               ((String[]) buf[6])[0] = rslt.getString(4, 10) ;
               ((boolean[]) buf[7])[0] = rslt.wasNull();
               ((String[]) buf[8])[0] = rslt.getString(5, 8) ;
               ((boolean[]) buf[9])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[10])[0] = rslt.getGXDate(6) ;
               ((boolean[]) buf[11])[0] = rslt.wasNull();
               ((String[]) buf[12])[0] = rslt.getString(7, 20) ;
               ((boolean[]) buf[13])[0] = rslt.wasNull();
               ((String[]) buf[14])[0] = rslt.getString(8, 20) ;
               ((boolean[]) buf[15])[0] = rslt.wasNull();
               ((String[]) buf[16])[0] = rslt.getString(9, 20) ;
               ((boolean[]) buf[17])[0] = rslt.wasNull();
               ((String[]) buf[18])[0] = rslt.getString(10, 20) ;
               ((boolean[]) buf[19])[0] = rslt.wasNull();
               ((String[]) buf[20])[0] = rslt.getString(11, 20) ;
               ((boolean[]) buf[21])[0] = rslt.wasNull();
               ((String[]) buf[22])[0] = rslt.getString(12, 20) ;
               ((boolean[]) buf[23])[0] = rslt.wasNull();
               ((short[]) buf[24])[0] = rslt.getShort(13) ;
               ((boolean[]) buf[25])[0] = rslt.wasNull();
               ((String[]) buf[26])[0] = rslt.getString(14, 10) ;
               ((String[]) buf[27])[0] = rslt.getString(15, 10) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setShort(2, ((Short) parms[1]).shortValue());
               stmt.setString(3, (String)parms[2], 10);
               stmt.setShort(4, ((Short) parms[3]).shortValue());
               stmt.setString(5, (String)parms[4], 20);
               stmt.setString(6, (String)parms[5], 20);
               stmt.setString(7, (String)parms[6], 20);
               stmt.setString(8, (String)parms[7], 20);
               stmt.setString(9, (String)parms[8], 20);
               stmt.setString(10, (String)parms[9], 20);
               stmt.setDate(11, (java.util.Date)parms[10]);
               stmt.setString(12, (String)parms[11], 8);
               stmt.setString(13, (String)parms[12], 10);
               stmt.setDate(14, (java.util.Date)parms[13]);
               stmt.setString(15, (String)parms[14], 8);
               stmt.setString(16, (String)parms[15], 10);
               break;
      }
   }

}

